﻿<?xml version="1.0" encoding="utf-8" ?>
<xs:schema
  targetNamespace="http://www.codeplex.com/JSClientPages/JSElements"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.codeplex.com/JSClientPages/JSElements">

  <xs:import namespace="http://www.w3.org/1999/xhtml" />


    <xs:element name="output">
        <xs:complexType>
            <xs:attribute name="value" />
        </xs:complexType>
    </xs:element>

    <xs:element name="forEach">
        <xs:complexType>
            <xs:complexContent>               
                <xs:extension base="xs:anyType">
                    <xs:attribute name="item" use="required"/>
                    <xs:attribute name="collection" use="required" />
                    <xs:attribute name="start" use="optional" />
                    <xs:attribute name="end" use="optional" />
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:element>

    <xs:element name="condition">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="if" minOccurs="1" maxOccurs="1" />
                <xs:element ref="then" minOccurs="1" maxOccurs="1" />
                <xs:element ref="else" minOccurs="0" maxOccurs="1" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:element name="if" type="xs:string" />
    <xs:element name="then" type="content" />
    <xs:element name="else" type="content"  />

    <xs:element name="switch">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="case" minOccurs="1" maxOccurs="unbounded">
                    <xs:complexType mixed="true">
                        <xs:complexContent>
                            <xs:extension base="content">                                
                                <xs:attribute name="if" type="xs:string" />
                            </xs:extension>
                        </xs:complexContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="default" type="content" minOccurs="0" maxOccurs="1" />
            </xs:sequence>
            <xs:attribute name="type" use="optional">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="simple" />
                        <xs:enumeration value="complex" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="value" type="xs:string" />           
        </xs:complexType>    
    </xs:element>
    

    <xs:element name="table">
        <xs:complexType>
            <xs:choice minOccurs="1" maxOccurs="unbounded">
                <xs:element ref="thead" />
                <xs:element ref="tfoot" />
                <xs:element ref="tbody" />
                <xs:element ref="tr" />
                <xs:element ref="html:thead" />
                <xs:element ref="html:tfoot" />
                <xs:element ref="html:tbody" />
                <xs:element ref="html:tr" />
                <xs:group ref="control" />
            </xs:choice>
            <xs:attributeGroup ref="html:attrs" />
            <xs:attributeGroup ref="html:cellhalign" />
            <xs:attributeGroup ref="html:cellvalign" />
        </xs:complexType>        
    </xs:element>

    <xs:element name="thead" type="tableBlock" />
    <xs:element name="tbody" type="tableBlock" />
    <xs:element name="tfoot" type="tableBlock" />
    <xs:element name="tr">
        <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="html:th" />
                <xs:element ref="html:td" />              
            </xs:choice>
            <xs:attributeGroup ref="html:attrs" />
            <xs:attributeGroup ref="html:cellhalign" />
            <xs:attributeGroup ref="html:cellvalign" />
        </xs:complexType>
    </xs:element>

    <xs:complexType name="content" mixed="true">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:any namespace="http://www.w3.org/1999/xhtml" />
            <xs:any namespace="##targetNamespace" />
         </xs:choice>
    </xs:complexType>

    <xs:complexType name="tableBlock">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="html:tr" />
            <xs:element ref="tr" />
            <xs:group ref="control" />
        </xs:choice>
        <xs:attributeGroup ref="html:attrs" />
        <xs:attributeGroup ref="html:cellhalign" />
        <xs:attributeGroup ref="html:cellvalign" />
    </xs:complexType>    




    <xs:group name="flow">
        <xs:choice>
            <xs:element ref="output" />
        </xs:choice>
    </xs:group>

    <xs:group name="block">
        <xs:choice>
            <xs:element ref="table" />
        </xs:choice>
    </xs:group>

    <xs:group name="control">
        <xs:choice>
            <xs:element ref="forEach" />
            <xs:element ref="condition" />
            <xs:element name="switch" />
        </xs:choice>
    </xs:group>
</xs:schema>